﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System.Security.Claims;
using 第二课堂评审系统.Models;

namespace 第二课堂评审系统.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TestController : ControllerBase
    {
        private readonly _MyDbContext Db;
        private readonly IOptionsSnapshot<JWTSettings> jwtSettingsOpt;
        public TestController(_MyDbContext db, IOptionsSnapshot<JWTSettings> jwtSettingsOpt)
        {
            Db = db;
            this.jwtSettingsOpt = jwtSettingsOpt;
        }


        [HttpGet]
        public ActionResult AddUser()
        {
            //User user = new User();
            //user.Name = "老七";
            //user.StuNum = 219971107;
            //user.passWord = "123456";
            //user.telPhone = "1111";
            //user.college = "2222";
            //user.track = "3333";
            //user.address = "4444";
            //user.contactAddress = "5555";
            //user.email = "6666";
            //Role role = new Role();
            //role.Name = "S1";
            //role.Users = user;

            //List<User> members = new List<User>();
            //List<Role> roles = new List<Role>();

            //user.Roles = roles;
            //user.Roles!.Add(role);

            //Partnar partnar = new Partnar();//模拟创建小组
            //Project project = new Project();//模拟创建项目
            //partnar.project = project;
            //project.Partnar = partnar;
            //project.isPassed = null;
            //project.isPassed = true;
         

            //partnar.members = members;
            //partnar.members.Add(user);
            //Db.Partnars.Add(partnar);
            //Db.Users.Add(user);
            //Db.Roles.Add(role);
            Project project=Db.Projects.Where(u=>u.Id==1).ToList().Single();
            project.isPassed = false;
            Db.SaveChanges();
            return Ok("添加成功");
        }

    }
}
